package com.xci.platform.core;

import java.util.HashMap;

/**
 * 通用字典集合
 */
@SuppressWarnings("unchecked")
public class GMap extends HashMap<String, Object> {
    /**
     * Associates the specified value with the specified key in this map.
     * If the map previously contained a mapping for the key, the old
     * value is replaced.
     *
     * @param key   key with which the specified value is to be associated
     * @param value value to be associated with the specified key
     * @return the previous value associated with <tt>key</tt>, or
     * <tt>null</tt> if there was no mapping for <tt>key</tt>.
     * (A <tt>null</tt> return can also indicate that the map
     * previously associated <tt>null</tt> with <tt>key</tt>.)
     */
    @Override
    public GMap put(String key, Object value) {
        super.put(key, value);
        return this;
    }

    @Override
    public GMap putIfAbsent(String key, Object value) {
          super.putIfAbsent(key, value);
        return this;
    }


    public static GMap newMap(String key, Object value) {
        GMap map = new GMap();
        map.put(key, value);
        return map;
    }

    public static GMap newMap() {
        GMap map = new GMap();
        return map;
    }
}
